package com.bcxj.apipassenger.controller;

import com.bcxj.apipassenger.Service.VerfivcationCodeService;

import com.bcxj.internalcommon.dto.ResponseResult;
import com.bcxj.internalcommon.dto.VerificationCodeDTO;
import com.bcxj.internalcommon.response.NumberCodeResponse;
import com.bcxj.internalcommon.response.TokenResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: VerificationCodeController
 * Package: com.bcxj.controller
 * Description:
 *
 * @Author BCXJ
 * @Create 2024/9/11 23:27
 * @Version 1.0
 * @Since 1.0
 */
@RestController
public class VerificationCodeController {

    @Autowired
    private VerfivcationCodeService verificationCodeService;


    /**
     * 手机验证码服务
     * 发送验证码
     * @param verificationCodeDTO 前端信息实体类
     * @return
     */
    @GetMapping("/verification-code")
    public ResponseResult<NumberCodeResponse> verificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO) {
        return verificationCodeService.generatorCode(verificationCodeDTO.getPassengerPhone());
    }


    @PostMapping("/verification-code-check")
    public ResponseResult<TokenResponse> verificationCodeCheck(@RequestBody VerificationCodeDTO verificationCodeDTO) {
        return verificationCodeService.checkCode(verificationCodeDTO);
    }

}
